What's the difference between sprintf() and printf()?
And can you explain them both for me please Thanks
edit... also, what is count++. is count something defined in a headerfile, or wha..? ++ just increments count?
What's the difference between sprintf() and printf()?
And can you explain them both for me please Thanks
edit... also, what is count++. is count something defined in a headerfile, or wha..? ++ just increments count?
Last edited by Brittany; 03-14-2005 at 11:56 PM.
printf displays formatted output to the standard output device. It takes any number of parameters* and depending on various sequences in the first argument to it, gives you different formatted ouput.
sprintf does the exact same thing, except instead of displaying it to an output device, it stores that in a string you pass to it.
The sequence:
Increments the value of object. So, depending on what datatype object is, it gets incremented by one.Code:object++
Quzah.
Hope is the first step on the road to disappointment.
Depends where did you see count++? Usually a variable is initiated within a function or passed to a function. count is probably initiated somewhere within the function.
As for printf and sprintf
sprintf basically copies a format similar to that you would use in printf except with sprintf it copies it to a string, as with printf it sends it to stdout.Code:int printf(const char *format, ...); int sprintf(char *str, const char *format, ...);
[edit]
damn quzah you beat me
[/edit]
When you say it sends it to stdout, do you mean it pretty much shows up on the monitor? And what do you mean by copies it to a string? When I said count++ it was inside a set ofand it wasnt defined anywhere in the progam. It was at the very end. ThanksCode:{ }
Last edited by Brittany; 03-15-2005 at 12:23 AM.
Well count was declared some place, or your code doesn't compile. stdout is the definition of the standard output device. This is commonly the monitor, though it doesn't have to be. Why don't you go look up the man pages, or search the forums for sprintf. Why, I bet there's even an example of it being used in teh FAQ.
Quzah.
Hope is the first step on the road to disappointment.
will do ^_^ thanks